<!DOCTYPE html>
<html>
    <head>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
        <meta charset="utf-8">
        <meta name="renderer" content=webkit>
        <!-- 引入vue -->
        <script src="../js/vue.js"></script>
        <!-- 引入组件库 -->
        <script src="../js/jQyery.js"></script>
        <script src="../js/layer/layer.js"></script>

        <script src="../js/element/element.js"></script>
        <script src="../js/new.js"></script>
        <!-- 引入样式 -->
        <link rel="stylesheet" href="../js/element/element.css">
        <link rel="stylesheet" href="../css/main.css">
        <link rel="stylesheet" href="../css/maincontent.css">
        <link rel="stylesheet" href="../css/newmain.css">

    </head>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
    <body>
        <div class="index_main"  onclick="hidediaolog()">
            <div class="index_mainhead" id="app" v-cloak >
                <div class="imh_left">
                    <img class="index_logo" src="../img/logowhite.png">
                    <el-tooltip class="item" effect="light" content="折叠" placement="right" v-if="!isCollapse" >
                        <img class="index_action" src="../img/logonext.png" v-on:click="changemenu">
                    </el-tooltip>

                    <el-tooltip class="item" effect="light" content="展开" placement="right" v-if="isCollapse">
                        <img class="index_action"  src="../img/right.png" v-on:click="changemenu">
                    </el-tooltip>

                </div>
                <div class="imh_right">
                    <div class="right_notice" v-on:click.stop="shownoticedialog">
                        <el-badge :value="12" :max="99" class="item">
                            <img class="right_noticeimg" src="../img/jinbao.png">
                        </el-badge>
                        <div class="noticelist" v-if="shownotice">
                            <div class="noticediv">
                                <img src="../img/yiji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticediv">
                                <img src="../img/erji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticediv">
                                <img src="../img/sanji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticediv">
                                <img src="../img/yiji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticediv">
                                <img src="../img/erji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticediv">
                                <img src="../img/sanji.png">
                                <span>一级警告提示文字辅助性触 字辅助性字辅助性字</span>
                            </div>
                            <div class="noticebottom">
                                <span>点击查看更多</span>
                            </div>
                        </div>
                    </div>
                    <div class="title_rightdiv" v-on:click.stop="showlangdialog">
                        <img :src="langinfo.img">
                        <span style="margin-left: 0.1rem;color: #fff">{{langinfo.name}}</span>
                        <img src="../img/xlwhite.png" style="margin-left: 0.05rem;">
                    </div>
                    <div class="head_line">

                    </div>
                    <div class="head_loginout">
                        <img src="../img/tuichu.png">
                    </div>
                </div>

                <div class="changelang" v-if="showlang" style="right: 0.14rem;top: 0.86rem">
                    <template v-for="item in langlist">
                        <div class="landiv" :class="{choselandiv:item.img===langinfo.img}" v-on:click="chosethis(item)">
                            <img :src="item.img">
                            <span>{{item.name}}</span>
                        </div>
                    </template>

                </div>
            </div>
            <div class="index_maincontent">
                <div class="imc_left" id="meun" v-cloak>
                    <div class="imc_userinfo" v-on:click.stop="showuserinfoactiondialog" v-if="!isCollapse">
                        <div class="userimg">
                            <img src="../img/tx.png">
                        </div>
                        <div class="userinfo" >
                            <div class="usertitle">
                                <span>智棚物联网</span>
                            </div>
                            <div class="userdesc">
                                <span>管理员</span>
                            </div>
                        </div>

                        <div class="userinfoaction" v-if="showuserinfoaction">
                            <div class="actionimg">
                                <img src="../img/sanjiao.png">
                            </div>
                            <div class="actionlist">
                                <div class="actiondiv">
                                    <span>基本资料</span>
                                </div>
                                <div class="actiondiv">
                                    <span>修改密码</span>
                                </div>
                                <div class="actiondiv">
                                    <span>退出</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="indexmenu">
                        <el-menu
                            ref="menu"
                            default-active="1"
                            class="el-menu-vertical-demo"
                            @open="handleOpen"
                            @close="handleClose"
                            :collapse="isCollapse"
                            background-color="#1A2F70"
                            text-color="#dfdfdf"
                            :unique-opened="true"
                            :collapse-transition="false">
                            <el-menu-item index="2" v-on:click="hidefarmlist">
                                <i class="el-icon-s-home"></i>
                                <span slot="title">首页</span>
                            </el-menu-item>
                            <el-submenu index="1">
                                <template slot="title">
                                    <i class="el-icon-s-grid"></i>
                                    <span>农场列表</span>
                                </template>
                                <el-menu-item-group class="seconditem" style="background: #253C82">
                                    <el-menu-item index="1-1">选项1</el-menu-item>
                                    <el-menu-item index="1-2">选项2</el-menu-item>
                                    <el-menu-item index="1-3">选项3</el-menu-item>
                                    <el-submenu index="1-4">
                                        <template slot="title">选项4</template>
                                        <el-menu-item class="thirditem" index="1-4-1">选项1</el-menu-item>
                                    </el-submenu>
                                </el-menu-item-group>




                            </el-submenu>

                            <el-menu-item index="3" v-on:click="hidefarmlist">
                              <i class="el-icon-s-platform"></i>
                              <span slot="title">智能场景</span>
                            </el-menu-item>
                            <el-menu-item index="4" v-on:click="hidefarmlist">
                              <i class="el-icon-s-order"></i>
                              <span slot="title">智棚服务</span>
                            </el-menu-item>
                        </el-menu>
                    </div>

                </div>
                <div class="imc_right" id="content" v-cloak>
                    <div class="imc_righthead">
                        <span>首页</span>
                    </div>
                    <div class="mainright_content">
                        <div class="fc_maindiv">
                            <div class="fc_maindivcontent">
                                <div class="farmvalvecontent farmvalvecontentnext">
                                    <div class="fvc_head">
                                        <div class="fvch_left">
                                            <div class="fvchl_tab" :class="{selecttab:activetab==0}" style="margin-left:0.2rem;" @click="changeactivetab(0)">
                                                <span>区域</span>
                                                <div class="tab_bottom" v-if="activetab==0"></div>
                                            </div>
                                            <div class="fvchl_tab" style="width: 1.4rem;" :class="{selecttab:activetab==1}" style="margin-left:0.4rem;" @click="changeactivetab(1)">
                                                <span>天气</span>
                                                <div class="tab_bottom" style="left:0.4rem" v-if="activetab==1"></div>
                                            </div>
                                            <div class="fvchl_tab" style="width: 1.4rem;" :class="{selecttab:activetab==2}" style="margin-left:0.4rem;" @click="changeactivetab(2)">
                                                <span>手动强制</span>
                                                <div class="tab_bottom" style="left:0.4rem" v-if="activetab==2"></div>
                                            </div>
                                            <div class="fvchl_tab" style="width: 1.4rem;" :class="{selecttab:activetab==3}" style="margin-left:0.4rem;" @click="changeactivetab(3)">
                                                <span>主菜单</span>
                                                <div class="tab_bottom" style="left:0.4rem" v-if="activetab==3"></div>
                                            </div>
                                        </div>
                                    </div>

                                </div>

                                <template v-if="activetab==0">
                                    <div class="clearfix control_allBox">
                                        <div class="control_box">
                                            <div class="control_current_title"><img src="../img/control_title_1.png">天气</div>
                                            <div class="control_bar_box">
                                                <span class="bar_left_text">{{ weather.leftWeather }}</span>
                                                <span class="bar_right_text">{{ weather.rightWeather }}</span>
                                                <div class="bar_center_text">
                                                    <div>{{ weather.value }}℃</div>
                                                    <div>温度</div>
                                                </div>
                                                <div class="control_bar" style="border-left-color:#496ECC;border-top-color:#9D9DA8;border-right-color:#FB4C2F;"></div>
                                                <div class="center">
                                                    <div :id="'dot' + 'Weather'" ref="dot" class="dot"
                                                    :class="[weatherBlue? 'dot-blue' : '', weatherGray? 'dot-gray' : '', weatherRed? 'dot-Red' : '']"></div>
                                                </div>
                                            </div>
                                            <div class="clearfix bar_weather_text_box">
                                                <div class="bar_weather_text bar_weather_text_left">湿度<span>{{ weather.humidity }}%</span></div>
                                                <div class="bar_weather_text">风向<span>{{ weather.windDirection }}</span></div>
                                                <div class="bar_weather_text bar_weather_text_left">光照<span>{{ weather.illumination }}KIX</span></div>
                                                <div class="bar_weather_text">降雨<span>{{ weather.rainfall }}</span></div>
                                                <div class="bar_weather_text bar_weather_text_left">风速<span>{{ weather.windSpeed }}M/S</span></div>
                                            </div>
                                        </div>
                                        <div class="control_box" v-for="(item,index) in regionList" :key="`regionList-${index}`">
                                            <div class="control_current_title"><img src="../img/control_title_2.png">{{ item.name }}</div>
                                            <div class="control_bar_box">
                                                <span class="bar_left_text">{{ item.leftValue }}</span>
                                                <span class="bar_right_text">{{ item.rightValue }}</span>
                                                <div class="bar_center_text">
                                                    <div>{{ item.value }}℃</div>
                                                    <div>温度</div>
                                                </div>
                                                <div class="control_bar" style="border-left-color:#496ECC;border-top-color:#9D9DA8;border-right-color:#FB4C2F;"></div>
                                                <div class="center">
                                                    <div :id="'dot' + index"  class="dot"
                                                         :class="[item.blueShow? 'dot-blue' : '', item.grayShow? 'dot-gray' : '', item.redShow? 'dot-Red' : '']"></div>
                                                </div>
                                            </div>
                                            <div class="clearfix bar_weather_text_box">
                                                <div class="bar_weather_text bar_text_left">降温状态<span>{{ item.type }}</span></div>
                                                <div class="bar_weather_text bar_text_left">降温状态<span>{{ item.temperature }}</span></div>
                                            </div>
                                        </div>

                                    </div>
                                </template>
                                <template v-if="activetab==1">

                                </template>
                                <template v-if="activetab==2">

                                </template>
                                <template v-if="activetab==3">

                                </template>
                            </div>


                        </div>
                    </div>
                </div>
            </div>

        </div>
    </body>

</html>
<script>
    var headvue=new Vue({
        el: '#app',
        data(){
            return {
                langinfo:{
                    name:"简体中文",
                    img:'../img/cn.png'
                },
                showlang:false,
                shownotice:false,
                isCollapse:false,
                langlist:[
                    {
                        img:'../img/cn.png',
                        name:'简体中文'
                    },
                    {
                        img:'../img/yy.png',
                        name:'English'
                    },
                    {
                        img:'../img/yy.png',
                        name:'English'
                    },
                    {
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },{
                        img:'../img/yy.png',
                        name:'English'
                    },

                ],


            }
        },
        computed: {

        },
        created() {

        },
        mounted(){



        },
        methods:{

            showlangdialog(){
                this.showlang=!this.showlang;
                this.shownotice=false;
                this.showuserinfoaction=false
            },
            hidediaolog(){
                this.showlang=false;
                this.shownotice=false;
                this.showuserinfoaction=false
            },
            showuserinfoactiondialog(){
                this.showuserinfoaction=!this.showuserinfoaction;
                this.shownotice=false;
                this.showlang=false;
            },
            chosethis(item){
                this.langinfo=item
                this.showlang=false;
            },
            shownoticedialog(){
                this.shownotice=!this.shownotice;
                this.showlang=false;
                this.showuserinfoaction=false


            },
              changemenu(){
                this.isCollapse=!this.isCollapse
                if(this.isCollapse){
                    $(".el-submenu__title span").hide();
                    $(".el-menu-item span").hide();
                    $(".el-submenu__title i").eq(1).hide();
                    $(".imc_left").css({"width":"auto","min-width":"auto"})
                    $(".indexmenu").css("height","100%")

                }
                else{
                    $(".imc_left").css({"width":"2.6rem","min-width":"200px"})
                    $(".indexmenu").css("height","calc(100% - 0.96rem)")
                }
            },
        },
        watch:{
            isCollapse(){
                meun.isCollapse=this.isCollapse
            }
        }
    })
    var meun=new Vue({
        el: '#meun',
        data(){
            return {
                showuserinfoaction:false,
                isCollapse:false,
            }
        },
        computed: {

        },
        created() {

        },
        mounted(){



        },
        methods:{

            hidediaolog(){
                this.showlang=false;
                this.shownotice=false;
                this.showuserinfoaction=false
            },
            showuserinfoactiondialog(){
                this.showuserinfoaction=!this.showuserinfoaction;
                this.shownotice=false;
                this.showlang=false;
            },


            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },


            hidefarmlist(){
                this.$refs["menu"].close("1")
            },

        }
    })
    var content=new Vue({
        el: '#content',
        data(){
            return {
                activetab:0,
                dataType:'0',
                regionList:[],
                weather:{},
                weatherBlue:false,
                weatherGray:false,
                weatherRed: false
            }
        },
        computed: {

        },
        created() {

        },
        mounted(){
            this.init()
            this.$nextTick(() => {
                this.barChange()
            });
        },
        methods:{
            init() {
                // this.getWeizhi()
                this.getWeatherData()
                this.getRegion()
            },
            hidefarmlist(){
                this.$refs["menu"].close("1")
            },
            changeactivetab(index){
                this.activetab=index;
            },
            barChange() {
                let obj = {}
                let section = '';
                let proportion = '';
                let degrees = '';
                let allDegrees = ''
                for(let i in this.regionList){
                    obj = this.regionList[i]
                    obj.blueShow = false;
                    obj.redShow = false;
                    obj.grayShow = false;
                    if(obj.value < obj.leftValue) {
                        obj.blueShow = true;
                        section = obj.leftValue - obj.min;
                        proportion = (obj.value - obj.min) / section;
                        degrees = Math.ceil(proportion * 90);
                        allDegrees = degrees + 135
                    }
                    if(obj.value > obj.rightValue) {
                        obj.redShow = true;
                        section = obj.max - obj.rightValue;
                        proportion = (obj.value - obj.rightValue) / section;
                        degrees = Math.ceil(proportion * 90);
                        allDegrees = degrees + 90 + 90 + 135
                    }
                    if(obj.value > obj.leftValue && obj.value < obj.rightValue) {
                        obj.grayShow = true;
                        section = obj.rightValue - obj.leftValue;
                        proportion = (obj.value - obj.leftValue) / section;
                        degrees = Math.ceil(proportion * 90)
                        allDegrees = degrees + 90 + 135
                    }
                    this.getWeizhi(i,allDegrees)
                }
            },
            getRegion() {
                let res = {data:[{
                        name: '区域一',
                        type: '模式二最大降温',
                        temperature: '22°摄氏度',
                        value: 11,
                        leftValue: 8,
                        rightValue: 33,
                        min: 0,
                        max: 50,
                    },{
                        name: '区域二',
                        type: '模式二最大降温',
                        temperature: '22°摄氏度',
                        value: 44,
                        leftValue: 5,
                        rightValue: 33,
                        min: 0,
                        max: 50,
                    },{
                        name: '区域三',
                        type: '模式二最大降温',
                        temperature: '22°摄氏度',
                        value: 3,
                        leftValue: 5,
                        rightValue: 33,
                        min: 0,
                        max: 50,
                    }]}
                this.regionList = res.data
                let obj = {}
                for(let i in this.regionList){
                    obj = this.regionList[i]
                    obj.blueShow = false;
                    obj.redShow = false;
                    obj.grayShow = false;
                    if(obj.value < obj.leftValue) {
                        obj.blueShow = true;
                    }
                    if(obj.value > obj.rightValue) {
                        obj.redShow = true;
                    }
                    if(obj.value > obj.leftValue && obj.value < obj.rightValue) {
                        obj.grayShow = true;
                    }
                }
            },
            getWeizhi(index,row) {
                let oDot = document.getElementById('dot' + index);
                let deg = row;
                let timer = null;
                let radius = oDot.offsetLeft; // 旋转半径

                let radian = (2*Math.PI/360)*deg;
                let theTop = Math.sin(radian)*radius;
                let theLeft = Math.cos(radian)*radius;
                oDot.style.top = theTop + 'px';
                oDot.style.left = theLeft + 'px';
                deg += 0.5;
                if (deg === 361) {
                    deg = 0;
                }
                // timer = setInterval(function() {
                //     // console.log('Math.PI',oDot.offsetLeft)
                //
                // },1);
            },
            getWeatherData() {
                this.weatherBlue = false;
                this.weatherRed = false;
                this.weatherGray = false;
                let res = {data:{
                        min: 0,
                        max : 40,
                        leftWeather: 5,
                        rightWeather: 33,
                        value: 28,
                        humidity: 100,
                        illumination: 11.4,
                        windSpeed: 100,
                        windDirection: '西南',
                        rainfall: '是'
                    }}
                let section = '';
                let proportion = '';
                let degrees = '';
                let allDegrees = ''
                this.weather = res.data
                if(this.weather.value < this.weather.leftWeather) {
                    this.weatherBlue = true;
                    section = this.weather.leftWeather - this.weather.min;
                    proportion = (this.weather.value - this.weather.min) / section;
                    degrees = Math.ceil(proportion * 90);
                    allDegrees = degrees + 135
                }
                if(this.weather.value > this.weather.rightWeather) {
                    this.weatherRed = true;
                    section = this.weather.max - this.weather.rightWeather;
                    proportion = (this.weather.value - this.weather.rightWeather) / section;
                    degrees = Math.ceil(proportion * 90);
                    allDegrees = degrees + 90 + 90 + 135
                }
                if(this.weather.value > this.weather.leftWeather && this.weather.value < this.weather.rightWeather) {
                    this.weatherGray = true;
                    section = this.weather.rightWeather - this.weather.leftWeather;
                    proportion = (this.weather.value - this.weather.leftWeather) / section;
                    degrees = Math.ceil(proportion * 90)
                    allDegrees = degrees + 90 + 135
                }
                this.getWeizhi('Weather',allDegrees)
            }
        }
    })
</script>
<script type="text/javascript">

    timer = setInterval(function() {

    },1);
</script>
<script src="../js/index.js"></script>
